import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:flutterlib/common/datacenter/user_center.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/net/retrofit/interest_api.dart';
import 'package:flutterlib/common/style/quhui_style.dart';
import 'package:flutterlib/common/utils/navigator_utils.dart';
import 'package:flutterlib/pages/base/base_sliver_list.dart';
import 'package:flutterlib/widgets/bussiness/post/interest_list_item.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_manger.dart';

class Page extends BaseSliverList {
  Page({Key key}) : super(key: key);

  @override
  InterestMinePageState createState() {
    return InterestMinePageState();
  }
}

///页面 KeepAlive ，同时支持 动画Ticker
class InterestMinePageState extends BaseSliverListState<Page> {
  SimplePullLoadManger manger;

  ///滑动监听
  final ScrollController scrollController = new ScrollController();

  @override
  getDataLogic(int page) async {
    print(page);

    var posts = await InterestApi.builder()
        .getMyInterests(currentUserId);
    return new DataResult(posts, true);
  }

  @override
  Widget renderItem(index, interest) {
    return InterestListItem(interest, onPressed: () {
      NavigatorUtils.gotoInterestDetail(context, interest.id);
    });
  }

  @override
  List<Widget> renderHeader(BuildContext context, bool innerBoxIsScrolled) {
    return <Widget>[];
  }

  @override
  renderActions() {
    return <Widget>[];
  }

  @override
  Widget renderLeading() {
    return MyBackButton(
      color: Colors.black,
    );
  }

  @override
  Widget renderTitle() {
    return Text("我的兴趣", style: QuhuiConstant.normalTextBold);
  }

  @override
  bool enablePullDown() {
    return false;
  }

  @override
  bool enablePullUp() {
    return false;
  }
}
